package com.social.serviceImpl;

import com.social.dao.RolePermissionMapper;
import com.social.pojo.Permission;
import com.social.pojo.RolePermissionKey;
import com.social.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RolePermissionServiceImpl implements RolePermissionService {
    @Autowired
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public int deleteByPrimaryKey(RolePermissionKey key) {
        int status = rolePermissionMapper.deleteByPrimaryKey(key);
        return status;
    }

    @Override
    public int insert(RolePermissionKey record) {
        int status = rolePermissionMapper.insert(record);
        return status;
    }

    @Override
    public int insertSelective(RolePermissionKey record) {
        int status = rolePermissionMapper.insertSelective(record);
        return status;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<RolePermissionKey> select(Integer rid, Integer pid) {
        List<RolePermissionKey> select = rolePermissionMapper.select(rid, pid);
        return select;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public RolePermissionKey selectByRoleId(Integer rid) {
        RolePermissionKey rolePermissionKey = rolePermissionMapper.selectByRoleId(rid);
        return rolePermissionKey;
    }

    @Override
    public int updateByRoleId(RolePermissionKey record) {
        int status = rolePermissionMapper.updateByRoleId(record);
        return status;
    }
}